|
|
|
|
|
|
|
The DrawPicture routine in program ObjPrint draws a diamond 1 inch tall and 1 inch wide on the form, picture box, or printer it is passed. As is mentioned in Chapter 1, Visual Basics, it is often convenient to work in a coordinate system other than inches. You might want to measure your graphics in centimeters, pixels, or some customized coordinate system with an unequal number of units per inch in the X and Y directions. You might also want to move the origin of the coordinate system to some place other than the upper-left corner of the drawing area. |
|
|
|
|
|
|
|
|
You can perform all of these steps using a form or picture box's scaling properties ScaleLeft, ScaleTop, ScaleWidth, and ScaleHeight. If you do, however, you cannot simply pass the Printer object into a drawing routine and expect the printed output to match what is displayed on the form. Unless the Printer object's scale properties match those of the form, the printed output will be incorrect. |
|
|
|
|
|
|
|
|
Unfortunately, the Printer's size and scale properties do not work the same way they do for a form or picture box. The Printer's Height and Width properties are determined by the paper the printer is using, and you cannot simply change them to match the output. Printers also do not print over the entire page. The printable area generally does not go all the way to the edges of the paper. Figure 5.5 shows how the dimensions of the paper relate to the printer's size and scale properties. |
|
|
|
|
|
|
|
|
Because you cannot easily change the size of the printer's drawing area to match that of the form, you must do a little extra work to make the printer's scale properties match those of the form. You need to find values for ScaleLeft, ScaleTop, ScaleWidth, and ScaleHeight that make the image of the form appear at its correct size, centered in the printable area. |
|
|
|
|
|
|
|
|
Figure 5.5
How paper size is related to printer properties. |
|
|
|
|
|